<template>
    <div>
     <h3>添加会员</h3>
     <table>
        <tr>
            <td>名称</td>
            <td><input type="text" v-model="x.name"></td>
        </tr>
        <tr>
            <td>性别</td>
            <td><input type="text" v-model="x.sex"></td>
        </tr>
        <tr>
            <td>手机号</td>
            <td><input type="text" v-model="x.tel"></td>
        </tr>
        <tr>
            <td>所属门店</td>
            <td>
                <select v-model="x.pname">
            
                    <option value="北京门店">北京门店</option>
                    <option value="上海门店">上海门店</option>
                    <option value="天津门店">天津门店</option>
                </select>
            </td>
        </tr>
        <tr>
            <td>来源渠道</td>
            <td>
                <select v-model="x.lu">
               
                    <option value="正规渠道">正规渠道</option>
                    <option value="特殊渠道">特殊渠道</option>
                </select>
            </td>
        </tr>
        <tr>
            <td></td>
            <td><input type="button" value="添加会员" @click="ok"></td>
        </tr>
     </table>
    </div>
</template>

<script setup lang="ts">
import axios from 'axios';
import { ref,reactive,onMounted } from "vue";
import moment from 'moment';
import { useRouter,useRoute } from "vue-router";
const router = useRouter();
const route = useRoute();

let x:any=reactive(
    {
  "name": "",
  "sex": "",
  "tel": "",
  "pname": "",
  "lu": ""
}
)
const ok=()=>{
    if(x.name=="")
{
    alert("用户名为空");
    return;
}
if(x.sex=="")
{
    alert("性别为空");
    return;
}
if(x.tel=="")
{
    alert("电话为空");
    return;
}
if(x.tel*0!=0)
{
    alert("电话请输入正规格式");
    return;
}
    axios({
        url:'https://localhost:7238/api/Emp/addlogin',
        method:'post',
        data:x
    })
    .then(res=>{
        console.log(res);
        if(res.data>0)
    {
        alert("添加成功");
    }
    })
    .catch(err=>{
        console.log(err);
    })
}



</script>

<style scoped>

</style>